package com.itheima.test01;

import java.util.Scanner;

public class test0 {
    public static void main(String[] args) {
        //遍历字符串（toCharArray 将字符串 转换成 字符数组）
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String s = sc.nextLine();

        char[] chs = s.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            System.out.println(chs[i]);
        }


        //统计字符出现的次数
        Scanner scc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String n = sc.nextLine();

        int bigCount = 0;
        int smalCount = 0;
        int numCount = 0;

        //toCharArray 将字符串 转换成 字符数组
        char[] chr = s.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            char c = chs[i];
            if (c >= 'A' && c <= 'Z') {
                bigCount++;
            } else if (c >= 'a' && c <= 'z') {
                smalCount++;
            } else if (c >= '0' && c <= '9') {
                numCount++;
            }
        }
        System.out.println("大写字母出现次数：" + bigCount);
        System.out.println("小写字母出现次数：" + smalCount);
        System.out.println("数字现次数：" + numCount);
    }
}
